package practice.tmp;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution406 {
    public int[][] reconstructQueue(int[][] people) {
        Arrays.sort(people, (o1, o2) -> {
            if (o1[0] != o2[0]) return o2[0] - o1[0];
            else return o1[1] - o2[1];
        });
        List<int[]> res = new ArrayList<>();
        for (int[] x : people) {
            res.add(x[1], x);
        }
        return res.toArray(new int[res.size()][]);
    }
}
